package com.kaishengit.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.springframework.stereotype.Repository;

import com.kaishengit.pojo.Linkman;
import com.kaishengit.pojo.Project;

@Repository
public class LinkmanDao extends BaseDao<Linkman, String> {

	public List<Linkman> findAll() {
		String hql = "from Linkman";
		Query query = getSession().createQuery(hql);
		@SuppressWarnings("unchecked")
		List<Linkman> linkmanList = query.list();

		return linkmanList;
	}

	public void update(Linkman linkman) {
		getSession().update(linkman);
	}

	public void dellinkman(String id) {
		SQLQuery query = getSession().createSQLQuery(
				"delete from t_linkman where id=:id");
		query.setParameter("id", id);
		query.executeUpdate();
	}

	public List<Linkman> findAllByPro(Project project) {
		String hql = "from Linkman where projectid=:id order by name desc";
		Query query = getSession().createQuery(hql);
		query.setParameter("id", project);
		@SuppressWarnings("unchecked")
		List<Linkman> linkmanList = query.list();

		return linkmanList;
	}

}
